package com.company.task4;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class EditStudentInfo {

    public static void editFunction(List<ArrayList> studentList){

        if(0 == studentList.size()){
            System.out.println("系统中无学生信息，请选择增加选项增添学生信息！");
            return;
        }

        Scanner sc = new Scanner(System.in);

        System.out.println("您想修改第几个学生的信息：");
        int editNo = sc.nextInt();
        ArrayList list = studentList.get(editNo-1);

        System.out.println("您想修改的信息是：1、学号  2、姓名  3、年龄");
        int infoNo = sc.nextInt();

        switch (infoNo){
            case 1:
                System.out.println("请输入该生新学号：");
                String newStudentNo = sc.next();
                list.set(0,newStudentNo);
                break;
            case 2:
                System.out.println("请输入该生新姓名：");
                String newStudentName = sc.next();
                list.set(1,newStudentName);
                break;
            case 3:
                System.out.println("请输入该生新年龄：");
                int newStudentAge = sc.nextInt();
                list.set(2,newStudentAge);
                break;
            default:
                System.out.println("无该选项，修改信息失败！");
                break;
        }
    }
}
